<!DOCTYPE html>
<html lang="en">

<head>
    <meta charset="UTF-8">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Document</title>
</head>

<body>
    <script>
        定义Person类
        class Person {
            constructor(name, age) {
                this.name = name;
                this.age = age;
            }
            //show方法
            show() {
                document.write(this.name + "," + this.age + "<br>");
            }
            //eat方法
            eat() {
                document.write("吃饭...");
            }
        }
        //使用Person类
        let p = new Person("张三", 23);
        p.show();
        p.eat();

        //定义对象
        let person = {
            name: "张三",
            age: 23,
            hobby: ["吃饭", "学习"],

            eat: function () {
                document.write("吃饭...");
            }
        }
        //使用person
        document.write(person.name + "," + person.age + "," + person.hobby[0]);
        person.eat();

    </script>
</body>

</html>